package com.powernode.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.powernode.domain.Sku;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
* @author 贺
* @description 针对表【sku(单品SKU表)】的数据库操作Mapper
* @createDate 2024-07-18 13:24:14
* @Entity com.powernode.pojo.Sku
*/
public interface SkuMapper extends BaseMapper<Sku> {

    @Update("update sku set stocks = stocks + #{count}, actual_stocks = actual_stocks + #{count}, version = version + 1 where sku_id = #{skuId} and version = #{version} and (stocks + #{count}) >= 0")
    Integer updateSkuStock(@Param("skuId") Long skuId, @Param("count") Integer count, @Param("version") Integer version);
}




